#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>
#include <strings.h>


int main()
{
    int sockfd = socket(AF_INET, SOCK_DGRAM, 0);

    struct sockaddr_in local;
    bzero(&local, sizeof local);
    local.sin_family = AF_INET;
    local.sin_addr.s_addr = INADDR_ANY;
    local.sin_port = htons(8080);

    int fd = bind(sockfd, (struct sockaddr*)&local, sizeof local);
    if (fd < 0);

    struct sockaddr_in peer;
    bzero(&peer, sizeof peer);
    socklen_t len = sizeof(peer);

    char buffer[1024];
    ssize_t n = recvfrom(sockfd, buffer, sizeof buffer, 0, (struct sockaddr*)&peer, &len);
    buffer[n] = 0;

    std::cout << buffer << std::endl;

    close(fd);
    close(sockfd);
    return 0;
}